package com.redhat.auth.web.system;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.opensymphony.xwork2.ActionSupport;
import com.redhat.auth.application.BizSystemApplication;
import com.redhat.auth.domain.BizSystem;
import com.redhat.redwork.coc.RedworkAction;

/**
 * 系统Action
 * @author Justin
 *
 */
public class SystemAction extends ActionSupport implements RedworkAction{

	private static final long serialVersionUID = 2431868933316912858L;

	@Valid
	BizSystem system;
	String id;
	
	BizSystemApplication bizSystemApplication;
	
	public void setBizSystemApplication(BizSystemApplication bizSystemApplication) {
		this.bizSystemApplication = bizSystemApplication;
	}

	public BizSystem getSystem() {
		return system;
	}

	public void setSystem(BizSystem system) {
		this.system = system;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	/**
	 * 新建一个系统
	 * @return
	 */
	public String create(){
		bizSystemApplication.createBizSystem(system);
		return "list";
	}
	
	/**
	 * 保存修改
	 * @return
	 */
	public String edit(){
		system = BizSystem.get(Long.parseLong(id));//bizSystemApplication.loadBizSystem(Long.parseLong(id));
		return "edit";
	}
	
	/**
	 * 保存修改
	 * @return
	 */
	public String save(){
		bizSystemApplication.saveBizSystem(system);
		return "list";
	}
}
